package PackDatos;
import java.sql.*;
public class GestionBD {
    Connection cn = null;
    Statement st = null;
    ResultSet rs = null;

    public Connection conectar() throws SQLException{
        try{
            Class.forName("com.mysql.jdbc.Driver");
            cn=DriverManager.getConnection("jdbc:mysql://localhost/javaschool","root","mysql");
            st=cn.createStatement(rs.TYPE_SCROLL_INSENSITIVE,rs.CONCUR_UPDATABLE);
        }catch(Exception ex){
             System.out.println("Error en la Conexion: "+ex.toString());
        }
        return cn;
    }

    public void desconectar() throws SQLException{
        rs.close();
        cn.close();
    }

    public ResultSet cargadatos(String sql) throws SQLException{
        rs=st.executeQuery(sql);
        return rs;
    }

    public void actualizar(String sql) throws SQLException{
        st.executeUpdate(sql);
    }

    public void cierracon() throws SQLException{
        cn.close();
    }

    public GestionBD(){

    }

}
